package org.com.yz.dubbo.web.ctrl;

import org.com.yz.common.config.ConfigureTest;
import org.com.yz.common.config.IDownloadService;
import org.com.yz.common.config.ServiceName;
import org.com.yz.common.util.CacheUtil;
import org.com.yz.common.util.DateUtil;
import org.com.yz.common.util.Signature;
import org.com.yz.dal.dao.model.MchConfig;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * 文件下载控制类
 *
 * @ClassName FileDownloadCtr
 * @Author wzc
 * @Date 2018/7/19 9:57
 **/
@RestController
public class FileDownloadCtr {

    @RequestMapping(value = "/api/pay/filedownload.htm")
    public String bankcard(String mchNo) {
        MchConfig config = CacheUtil.me().getMchConfigInfo(mchNo, "0");
        //MchConfig config = new MchConfig();
        HashMap<String, String> paramMap = new HashMap<>();
        paramMap.put("timestamp", DateUtil.getSeqString());
        paramMap.put("appid", config.getApp_id());
        paramMap.put("service", ServiceName.getAcquireDownload());
        paramMap.put("ver", ServiceName.getVer());
        paramMap.put("download_type", "01");   //01 银行代码下载
        paramMap.put("sign_type", ServiceName.getSign_typeRsa());
        paramMap.put("mac", Signature.generateMAC(paramMap, mchNo));
        System.out.println(IDownloadService.download(ConfigureTest.EP_DEV_API, paramMap, "E:\\bankfile.txt", mchNo));

        return null;

    }


}
